<template>
    <div class="order-pay-info">
        <div class="method body">
            <div class="header">支付方式</div>
            <div class="section">
                <div
                    class="item row"
                    :class="{ 'item-active': payMethod === method.name }"
                    v-for="(method, index) in methodList"
                    :key="index"
                    @click="changePayMethod(method)"
                >
                    <div class="icon">
                        <img
                            :src="require(`@/assets/icon/${method.icon}.png`)"
                        />
                    </div>
                    <span>{{ method.text }}</span>
                    <div class="icon" v-if="payMethod === method.name">
                        <img :src="require(`@/assets/icon/pay_active.png`)" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            payMethod: "cash",

            methodList: [
                { text: "柜台付款", name: "cash", icon: "pay_cash" },
                { text: "微信支付", name: "wechart", icon: "wechat" }
            ]
        };
    },

    methods: {
        changePayMethod(item) {
            this.payMethod = item.name;
            this.$emit("change", {
                name: item.name
            });
        }
    }
};
</script>


<style lang="less" scoped>
.order-pay-info {
    font-size: 28px;
    .body {
        background: #fff;
        padding: 0 30px 20px 30px;
        margin-bottom: 20px;

        .header {
            padding: 30px 0;
        }

        .section {
            .item {
                margin: 0 10px;
                padding: 20px 0;

                .icon {
                    width: 40px;
                    margin-right: 20px;
                }

                span {
                    flex: 1 1 auto;
                }
            }
        }
    }
}
</style>